package com.shopping.entity;

import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDateTime;

@Data
@TableName("orders")
public class Order {
    @TableId(type = IdType.AUTO)
    private Long id;

    @TableField("order_number")
    private String orderNumber;

    @TableField("user_id")
    private Long userId;

    @TableField("username")
    private String username;

    @TableField("product_id")
    private Long productId;

    @TableField("quantity")
    private Integer quantity = 1;

    @TableField("total_amount")
    private BigDecimal totalAmount;

    @TableField("order_points")
    private Integer orderPoints = 0;

    @TableField("order_date")
    private LocalDateTime orderDate;

    @TableField("address")
    private String address;

    @TableField("payment_method")
    private PaymentMethod paymentMethod;

    @TableField("contact_phone")
    private String contactPhone;

    @TableField("shipping_method")
    private ShippingMethod shippingMethod;

    @TableField("order_status")
    private OrderStatus orderStatus = OrderStatus.PENDING;

    @TableField("remarks")
    private String remarks;

    @TableField("discount_rate")
    private BigDecimal discountRate;

    @TableField("discount_amount")
    private BigDecimal discountAmount;

    @TableField("points_awarded")
    private Integer pointsAwarded;

    @TableField(exist = false)
    private User user;

    @TableField(exist = false)
    private Product product;

    public enum PaymentMethod {
        CASH("现金"),
        CREDIT_CARD("信用卡"),
        DEBIT_CARD("借记卡"),
        ALIPAY("支付宝"),
        WECHAT("微信支付"),
        BANK_TRANSFER("银行转账");

        private final String displayName;

        PaymentMethod(String displayName) {
            this.displayName = displayName;
        }

        public String getDisplayName() {
            return displayName;
        }
    }

    public enum ShippingMethod {
        EXPRESS("快递"),
        STANDARD("标准配送"),
        PICKUP("自提");

        private final String displayName;

        ShippingMethod(String displayName) {
            this.displayName = displayName;
        }

        public String getDisplayName() {
            return displayName;
        }
    }

    public enum OrderStatus {
        PENDING("待付款"),
        PAID("已付款"),
        SHIPPED("已发货"),
        COMPLETED("已完成"),
        CANCELLED("已取消");

        private final String displayName;

        OrderStatus(String displayName) {
            this.displayName = displayName;
        }

        public String getDisplayName() {
            return displayName;
        }
    }
}